package com.lx.test;

import java.util.Arrays;
import java.util.Comparator;

public class sort {
    public static void main(String[] args) {
        Integer arr[] = {6,1,2,7,9,3,4,5,10,8};
//        Arrays.sort(arr);

        Arrays.sort(arr, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                //o1-o2为升序序，o2-o1为降序，内部实现通过二者相减的返回值来确定元素应该放置的位置
                return o2-o1;
            }

        });
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
